package com.hui.account.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import androidx.annotation.Nullable;

/**
 * SQLite数据库初始化配置
 */
public class DatabaseConfig extends SQLiteOpenHelper {

    public DatabaseConfig(@Nullable Context context) {
        super(context, "account.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // 1、创建欠款记录表
        String sql = "create table record(" +
                "id integer primary key autoincrement," +
                "icon integer," +
                "userId integer," +
                "type integer," +
                "status integer," +
                "imageName text," +
                "pay text," +
                "remark text," +
                "money text," +
                "time text," +
                "year integer," +
                "month integer," +
                "day integer," +
                "payTime text," +
                "createTime text" +
                ")";

        db.execSQL(sql);

        // 2、创建客户表
        sql = "create table user(" +
                "id integer primary key autoincrement," +
                "userName text," +
                "phone text," +
                "remark text," +
                "status integer" +
                ")";

        db.execSQL(sql);

        // 3、创建文件表
        sql = "create table file(" +
                "id integer primary key autoincrement," +
                "name text," +
                "path text" +
                ")";

        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
